Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tarkista lommakkeella tallennettavien määräysryhmien lyhyet nimet #197

Conversation

nmaarnio
Copy link
Collaborator

No description provided.

Now PlanManager has a variable for reg. groups from active plan that is updated when needed.
Previously all regulation groups were read from DB every time reg. groups from active plan
were needed for some form.
@nmaarnio nmaarnio force-pushed the 158-tarkistus-siitä-ettei-käyttäjä-ole-lisäämässä-määräysryhmää-olemassa-olevalla-lyhyellä-nimellä branch from c200e5c to d1800d0 Compare February 21, 2025 08:39
@@ -57,7 +62,9 @@ def __init__(
self.regulation_groups_tree_layout: QVBoxLayout

# INIT
self.regulation_group_libraries = regulation_group_libraries
self.existing_group_short_names = active_plan_regulation_groups_library.get_short_names()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voisi muuttaa set:ksi, niin haku tehokkaampaa. Ei nyt oikeesti tässä mittaluokassa merkittävää.
Tai sitten tuon get_short_names() voisi muuttaa palauttamaan suoraan set:n.

Suggested change
self.existing_group_short_names = active_plan_regulation_groups_library.get_short_names()
self.existing_group_short_names = set(active_plan_regulation_groups_library.get_short_names())

Comment on lines 149 to 157
def get_short_names(self) -> list[str]:
"""Returns list of non-empty short names (letter codes) of regulation groups part of the library."""
short_names = []
for category in self.regulation_group_categories:
for regulation_group in category.regulation_groups:
short_name = regulation_group.short_name
if short_name:
short_names.append(short_name)
return short_names
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saisi hoidettua yhdellä list comprehensionilla, mutta en sitte tiiä kumpi on selkolukuisempi.
Tai oikeestaan, jos ei järjestyksellä tai duplikaateilla ole merkitystä, niin voisi muuttaa palauttamaan suoraan set:n, jolloin haku tästä olisi tehokkaampaa.

Suggested change
def get_short_names(self) -> list[str]:
"""Returns list of non-empty short names (letter codes) of regulation groups part of the library."""
short_names = []
for category in self.regulation_group_categories:
for regulation_group in category.regulation_groups:
short_name = regulation_group.short_name
if short_name:
short_names.append(short_name)
return short_names
def get_short_names(self) -> set[str]:
return {
regulation_group.short_name
for category in self.regulation_group_categories
for regulation_group in category.regulation_groups
if regulation_group.short_name
}

@nmaarnio nmaarnio force-pushed the 158-tarkistus-siitä-ettei-käyttäjä-ole-lisäämässä-määräysryhmää-olemassa-olevalla-lyhyellä-nimellä branch from d1800d0 to ab824b3 Compare February 24, 2025 06:50
@nmaarnio nmaarnio merged commit f657c3a into main Feb 24, 2025
7 checks passed
@nmaarnio nmaarnio deleted the 158-tarkistus-siitä-ettei-käyttäjä-ole-lisäämässä-määräysryhmää-olemassa-olevalla-lyhyellä-nimellä branch February 24, 2025 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tarkistus siitä, ettei käyttäjä ole lisäämässä määräysryhmää olemassa olevalla lyhyellä nimellä
2 participants